import pymysql
class Db():
    def __init__(self) -> None:
        self.conn = pymysql.connect(host='127.0.0.1', port=3306,user='root',
        password='111222',db='py99',cursorclass=pymysql.cursors.DictCursor)
        self.cursor = self.conn.cursor()

    def find(self, sql):
        self.cursor.execute(sql)
        res = self.cursor.fetchone()
        return res

    def find_all(self, sql):
        self.cursor.execute(sql)
        res = self.cursor.fetchall()
        return res

    def update(self, sql):
        self.cursor.execute(sql)
        return self.cursor.lastrowid

    def commit(self):
        self.conn.commit()


    def rollback(self):
        self.conn.rollback()

db = Db()